<!DOCTYPE html>
<html lang = "pt-BR">
    <head>
        <?php
        session_start();
        include_once'bloco/head.php';
        include_once '../control/conexao.php';
        include_once '../control/valida_sessao.php';

        function __autoload($classe) {
            include_once"../model/{$classe}.class.php";
        }
        ?>
        <link href="bootstrap/css/morris.css" rel="stylesheet">
    </head>
    <body>      
        <div id="wrapper">
            <?php
            include_once'bloco/navbar.php';
            include_once '../control/valida_perfil.php';
            ?>
            <div id="page-wrapper">
                <?php include_once 'bloco/banner.php'; ?>                  
                <div class="row">
                    <div class=" panel panel-success">
                        <div class="panel-heading">
                            <p class="panel-title"><i class = "glyphicon glyphicon-th-large"></i> Listar Processo</p>
                        </div>
                        <div class="panel-body">
                            <?php
                            if (isset($_GET['matricula'])) {
                                $_SESSION['matricula'] = $_GET['matricula'];
                            }

                            if (isset($_GET['pg'])) {
                                $pg = $_GET['pg'];
                            } else {
                                $pg = 0;
                            }
                            $numreg = 10; // Quantos registros por página vai ser mostrado
                            $inicial = $pg * $numreg;
                            $limite = "LIMIT $inicial, $numreg";

                            $processo = new processo();
                            $processo->matricula = $_SESSION['matricula'];
                            $processoDAO = new processoDAO();

                            $arProcesso = $processoDAO->listar($processo, $limite);
                            $quantreg = count($processoDAO->listar($processo, NULL));
                            ?>
                            <table class="table table-responsive table-striped table-condensed">
                                <tr>
                                    <td align="center"><strong>Protocolo</strong></td>
                                    <td align="center"><strong>Inicio</strong></td>
                                    <td align="center"><strong>Fim</strong></td>
                                    <td align="center"><strong>Status</strong></td>
                                </tr>
                                <?php
                                for ($c = 0; count($arProcesso) > $c; $c++) {
                                    $id_status = $arProcesso[$c]->id_status;
                                    $consulta_status = mysql_query("SELECT * FROM status WHERE id_status='$id_status'");
                                    $status = mysql_result($consulta_status, 0, 'status_nome');
                                    ?>
                                    <tr>
                                        <td align="center"><a href="exibir_processo.php?processo=<?php echo $arProcesso[$c]->id_processo; ?>"><?php echo $arProcesso[$c]->id_processo; ?></a></td>
                                        <td align="center"><?php echo $arProcesso[$c]->data_inicio; ?></td>
                                        <td align="center"><?php echo $arProcesso[$c]->data_fim; ?></td>
                                        <td align="center"><?php echo utf8_encode($status); ?></td>
                                    </tr>
                                <?php } ?>
                            </table>
                            <div class = "col-lg-4 col-lg-offset-4" align = "center">
                                <?php
                                include 'bloco/paginacao.php';
                                ?>                                
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php
        include_once'bloco/scripts.php';
        ?>
        <script type="text/javascript">
            function confirma() {
                var opcao = confirm("Excluir este usuário?");
                if (opcao == false) {
                    return false
                    exit();
                }
            }
        </script>
    </body>
</html>